package com.Camellia.zy_video.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.Camellia.zy_video.entity.Category;
import com.Camellia.zy_video.entity.Video;
import com.Camellia.zy_video.service.CategoryService;
import com.Camellia.zy_video.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author
 * @version 1.0
 * 视频频道业务接口
 */
@RequestMapping("/category")
@RestController
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    @GetMapping("/list")
    public R list(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "5") Integer limit){
        List<Category> list = categoryService.list(new Page<Category>(page, limit));

        //查询总记录数
        long count = categoryService.count();
        return R.ok("查询成功").setData(list).setCount(count);
    }

}
